export default {
    data() {
        return {
            showLoading: false,
        }
    },
    methods: {
       //表格内容样式
        cellStyle({
            row,
            column,
            rowIndex,
            columnIndex
        }) {
            if (columnIndex == 0 && rowIndex != 0) {
                return "padding:0.15rem 0;border-top:1px solid #d6cfe2";
            } else if (columnIndex == 0 && rowIndex == 0) {
                return "padding:0.15rem;";
            } else if (columnIndex != 0 && rowIndex == 0) {
                return "padding:0.15rem 0;border-left:1px solid #d6cfe2;";
            } else {
                return "padding:0.15rem 0;border-left:1px solid #d6cfe2;border-top:1px solid #d6cfe2";
            }
        },
        //无内边表格内容样式
        cellStyle_noPadding({
            row,
            column,
            rowIndex,
            columnIndex
        }) {
            if (columnIndex == 0 && rowIndex != 0) {
                return "padding:0;border-top:1px solid #d6cfe2";
            } else if (columnIndex == 0 && rowIndex == 0) {
                return "padding:0;";
            } else if (columnIndex != 0 && rowIndex == 0) {
                return "padding:0;border-left:1px solid #d6cfe2;";
            } else {
                return "padding:0;border-left:1px solid #d6cfe2;border-top:1px solid #d6cfe2";
            }
        },
        // 表格头样式
        cellHeadStyle({
            row,
            rowIndex,
            column,
            columnIndex
        }) {
            if (rowIndex == 0 && columnIndex == 0) {
                return "tableStyle_second";
            } else {
                return "tableStyle_first";
            }
        },
        tableRowClassName({
            row,
            rowIndex
        }) {
            if (rowIndex % 2 == 1) {
                return "warning-row";
            } else if (rowIndex % 2 == 0) {
                return "success-row";
            }
            return "";
        },

        
         /* 第二套表格样式 用于流程下面附表 table下面套el-table*/
        // 表格头样式
        cellStyle_attached({
            row,
            column,
            rowIndex,
            columnIndex
        }) {
            if (columnIndex == 0 && rowIndex != 0) {
                return "border-top:1px solid #90badd !important;";
            } else if (columnIndex == 0 && rowIndex == 0) {
                return "";
            } else if (columnIndex != 0 && rowIndex == 0) {
                return "border-left:1px solid #90badd !important;";
            } else {
                return "border-left:1px solid #90badd !important;border-top:1px solid #90badd !important;";
            }
        },
        cellHeadStyle_attached({
            row,
            rowIndex,
            column,
            columnIndex
        }) {
            if (rowIndex == 0 && columnIndex == 0) {
                return "attachedList_second";
            } else {
                return "attachedList_first";
            }
        },


        //得到当前时间  年月日时分秒  流程申请时间专用
        getNowTime(){
            var date = new Date()
            var y = date.getFullYear()
            var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
            var d = (date.getDate()< 10 ? '0' + (date.getDate()) : date.getDate())
            var h = (date.getHours()< 10 ? '0' + (date.getHours()) : date.getHours())
            var m = (date.getMinutes()< 10 ? '0' + (date.getMinutes()) : date.getMinutes())
            var s = (date.getSeconds()< 10 ? '0' + (date.getSeconds()) : date.getSeconds())
            return y+'-'+M+'-'+d+' '+h+':'+m+':'+s
        },

        //合计方法
        getSummaries(param) {
            const { columns, data } = param;
            const sums = [];
            columns.forEach((column, index) => {
            if (index === 0) {
                sums[index] = "总计";
                return;
            }
            const values = data.map(item => Number(item[column.property]));
            if (!values.every(value => isNaN(value))) {
                sums[index] = values.reduce((prev, curr) => {
                const value = Number(curr);
                if (!isNaN(value)) {
                    return prev + curr;
                } else {
                    return prev;
                }
                }, 0);
                sums[index] += ' ';
            } else {
                sums[index] = '';
            }
            });
            return sums;
        },
        }
};